#include "HardwareProfile.h"

unsigned char Key_Tx[6]=
{
	0xF1, 0x06, 0x01, 0x10, 0x08, 0x8E
};
void KeyProc(void)
{	
	if(RC0==1)
	{
		gFlags.bkey=0;
		return;		
	}
	__delay_ms(20);
	if(RC0==1)
	{
		gFlags.bkey=0;
		return;	
	}
	if(gFlags.bkey)
		return;
	Uart1_PutChars(Key_Tx,6);
	BEEPIO=1;
	__delay_20ms(7);
	BEEPIO=0;
	gFlags.bkey=1;
}
void Calc(unsigned char rx)
{
	unsigned char dl, cl;//, t1, t2, t3, t4, t5, t6, t7, t8;
	dl = x1;
	cl = rx;
	dl += cl;
	cl = x2;
	cl += dl;
	dl = x3;
	dl += cl;
	cl = x4;
	cl += dl;
	dl = 0x37;
	dl += cl;
	cl = 0x49;
	cl ^= dl;
	dl = 0x13;
	dl ^= cl;
	cl = 0xc1;
	cl += dl;
	dl = x3;
	x4 = dl;
	dl = x2;
	x3 = dl;
	dl = x1;
	x2 = dl;
	x1 = cl;
}
